﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<head>
<%@ include file="/include/include.jsp" %>
<script>
function sendMail(){
			//alert('发送邮件');
		if(!isSelected('idss')){
			alert('您必须选择一行！');
			return;
		}
		$('currPageId1').value = document.getElementsByName('page.currentPage')[0].value;
		$('ids').value=getValuesByTagName('idss');
		$('form').submit();
	}
function exportDelivery(){
	if(!isSelected('idss')){
		alert('您必须选择一行！');
		return;
	}

	$('ids').value=repeatCheckBoxAndIsNumber(getAllCheckBox());

	/////$('ids').value=getValuesByTagName('idss');
	$('form').action ='${ctx}/delivery/list/exportdelivery';
	$('form').submit();
}
function exprotDeliveryDetail(){
if(!isSelected('idss')){
		alert('您必须选择一行！');
		return;
	}
	var ids =getValuesByTagName('idss');
	
	var selectIds = ids.split(',');
	var v=0;
	for(var i=0,len = selectIds.length;i<len;i++){
		if( i == 0){
			v =$(selectIds[i]+'warehouse').value;
		}
		 
		if( v != $(selectIds[i]+'warehouse').value){
			alert('只能选择同一家仓储商的PO单！');
			return;
		}
	}
	$('ids').value=ids;
	$('form').action ='${ctx}/delivery/list/exportdeliverydetail';
	$('form').submit();
}


function changeStatus(){
	if(!isSelected('idss')){
		alert('您必须选择一行！');
		return;
	}
	var ids =getValuesByTagName('idss');
	var selectIds = ids.split(',');
	for(var i=0,len = selectIds.length;i<len;i++){
		if($(selectIds[i]+'status').value != 'Send'){
			alert('只能选择未签收的订单！');
			return;
		}
	}
	if(confirm("您确定签收吗？")){
		$('ids').value=getValuesByTagName('idss');
		$('currPageId1').value = document.getElementsByName('page.currentPage')[0].value;
		$('form').action ='${ctx}/delivery/deliverylist/changestatus';
		$('form').submit();
	}
}
	

	function setMail(id){
		$('form').action = "${ctx}/delevery/deliverylist/sendmail/"+id;
		$('currPageId1').value = document.getElementsByName('page.currentPage')[0].value;
		$('form').submit();
	}

	function updateStatus(){
		//alert('aa');
			$('updateForm').action = "${ctx}/delivery/list/save";
			$('currPageId').value = document.getElementsByName('page.currentPage')[0].value;
			$('updateForm').submit();
	//alert($('currPageId').value);
			return false;
		
		}

</script>
</head>

<body>
	
	<%@ include file="/include/header.jsp" %>

	<%@ include file="/include/menu.jsp" %>
	<form id='form' action="${ctx}/delevery/deliverylist/sendmails/" method="post">
		<input type="hidden" name="ids" id='ids' />
		<input  type = "hidden" id = "currPageId1" name = "currPageId1" />
	</form>
			
	<div id="mainContent">
		<h2><a href="${ctx}/${menu.url}">${menu.description}</a>&nbsp;-&nbsp;<a href="${ctx}/${empty currViewBarSubMenu_ ? submenu.url : currViewBarSubMenu_.url}">${empty currViewBarSubMenu_ ? submenu.description : currViewBarSubMenu_.description}</a></h2>
		
		<div class="tool-bar">
			
			<div title="${menu.description} - ${empty currViewBarSubMenu_ ? submenu.description : currViewBarSubMenu_.description} - 查询${empty currViewBarSubMenu_ ? submenu.description : currViewBarSubMenu_.description}"  href="${ctx}/delivery/deliverylist/search" class="modal-window modal-link">过滤查询</div>
			<a href="javascript:sendMail()" title="发送邮件">发送邮件</a>
			<a href="javascript:exprotDeliveryDetail()" >导出送货单明细</a>
			<a href="javascript:exportDelivery()" >导出送货单</a>
			<a href="javascript:changeStatus()" >批量签收</a>
		</div>
		
		<div class="grid-list">
			<table class="grid" cellspacing="0"  url="${ctx}/delivery/deliverylist/list">
				<thead>
					<tr>
						<td><input type="checkbox" name="aaa" onclick="clearAll(this,'idss')"/></td>
						<td  orderBy_="deliveryorder.number" class="${orderParameters['deliveryorder.number']}">DO单号</td>
						<td>PO单号</td>
						<td>储运商</td>
						<td>ASC代码</td>
						<td>ASC简称</td>
						<td>区域</td>
						<td orderBy_="deliveryorder.deliveryDate" class="${orderParameters['deliveryorder.deliveryDate']}">订单日期</td>
						<td>状态</td>
						<td>操作</td>
					</tr>
				</thead>
				<tbody>
					<c:forEach var="deliveryOrder" items="${deliveryOrders}">
						<input type="hidden" id="${deliveryOrder.id}status" value="${deliveryOrder.deliveryStatus}"/>
						<input type="hidden" id="${deliveryOrder.id}warehouse" value="${deliveryOrder.warehouse.id}"/>
						<tr onmouseover="this.style.backgroundColor= '#A0CFEC'" class='${deliveryOrder.className}' onmouseout="this.style.backgroundColor= '#ffffff'">
							<td><input type="checkbox" name="idss"  value="${deliveryOrder.id}"/></td>
							<td>
								<div class="info">
									<span>
										<a href="${ctx}/delivery/deliverydetails/${deliveryOrder.id}">	
											${deliveryOrder.number}
										</a>	
									</span>
								</div>
							</td>
							<td>
								<div class="info">
									<span>
										<a href="${ctx}/purchase/purchasedetails/${deliveryOrder.purchaseOrder.id}">	
											${deliveryOrder.purchaseOrder.orderNumber}
										</a>	
									</span>
								</div>
								
							
							</td>
							<td>${deliveryOrder.warehouse.name}</td>
							<td>${deliveryOrder.maintenanceStation.number}</td>
							<td>${deliveryOrder.maintenanceStation.name}</td>
							<td>${deliveryOrder.maintenanceStation.region.name }</td>
							<td><fmt:formatDate value="${deliveryOrder.deliveryDate}" pattern="yyyy-MM-dd"/></td>
							<td>${deliveryOrder.deliveryStatus.aliseName}</td>
							<td class="tool-bar-tr">
								<a href="javascript:setMail(${deliveryOrder.id});"  title="发送邮件">
									<img src="${ctx}/static/images/send-mail.png"  border="0" alt="发送邮件" />
								</a>
								<c:if test="${deliveryOrder.canEditStatus}">
									<div  title="${menu.description} - ${submenu.description} - ${submenu.description}编辑"  href="${ctx}/delivery/list/${deliveryOrder.id}/edit" class="modal-window modal-link" >
										<img src="${ctx}/static/images/edit.png" alt="" />
									</div>
								</c:if>
							</td>
						</tr>
					</c:forEach>
				</tbody>
			</table>
			<t:page action="${ctx}/delivery/deliverylist/list"/>
		</div>
	</div>
	
	
	
	<%@ include file="/include/script.jsp" %>
	<script>
		setCheckedTag(document.getElementById('pageCheckIds').value);
	</script>
</body>

</html> 